package com.example.myapplication3.video.bean;

import android.net.Uri;

public class VideoItem {
    private long id;
    private String name;
    private String path;
    private Uri uri;
    private long size;
    private long duration;
    private long dateAdded;
    private long dateModified;
    private String mimeType;
    private int width;
    private int height;

    public VideoItem(long id, String name, String path, Uri uri, long size, long duration,
                     long dateAdded, long dateModified, String mimeType, int width, int height) {
        this.id = id;
        this.name = name;
        this.path = path;
        this.uri = uri;
        this.size = size;
        this.duration = duration;
        this.dateAdded = dateAdded;
        this.dateModified = dateModified;
        this.mimeType = mimeType;
        this.width = width;
        this.height = height;
    }

    // Getters
    public long getId() { return id; }
    public String getName() { return name; }
    public String getPath() { return path; }
    public Uri getUri() { return uri; }
    public long getSize() { return size; }
    public long getDuration() { return duration; }
    public long getDateAdded() { return dateAdded; }
    public long getDateModified() { return dateModified; }
    public String getMimeType() { return mimeType; }
    public int getWidth() { return width; }
    public int getHeight() { return height; }

    public String getFormattedSize() {
        if (size <= 0) return "0 B";
        final String[] units = new String[]{"B", "KB", "MB", "GB", "TB"};
        int digitGroups = (int) (Math.log10(size) / Math.log10(1024));
        return String.format("%.1f %s", size / Math.pow(1024, digitGroups), units[digitGroups]);
    }

    public String getFormattedDate() {
        return android.text.format.DateFormat.format("yyyy-MM-dd HH:mm", dateAdded * 1000).toString();
    }

    public String getFormattedDuration() {
        long seconds = duration / 1000;
        long minutes = seconds / 60;
        seconds = seconds % 60;
        return String.format("%02d:%02d", minutes, seconds);
    }

    public String getResolutionInfo() {
        return width + "×" + height;
    }
}